package com.zhijian.warehouse.manage.service;

import com.zhijian.util.page.Page;
import com.zhijian.warehouse.manage.entity.dto.stock.StockActionDto;
import com.zhijian.warehouse.manage.entity.export.StoreExport;
import com.zhijian.warehouse.manage.entity.po.Store;
import com.zhijian.warehouse.manage.entity.vo.request.StoreSaveOrUpdateVo;
import com.zhijian.warehouse.manage.entity.vo.request.StoreSearchVo;
import com.zhijian.warehouse.manage.entity.vo.request.StoreWarehouseLocationSearchVo;
import com.zhijian.warehouse.manage.entity.vo.response.StoreVo;
import com.zhijian.warehouse.manage.entity.vo.response.StoreWarehouseLocationProjectVo;
import com.zhijian.warehouse.manage.entity.vo.response.StoreWarehouseLocationVo;
import com.zhijian.warehouse.manage.entity.vo.response.StoreWarehouseVo;

import java.math.BigDecimal;
import java.util.List;

/**
 * 库存管理 业务处理层
 *
 * @author auto
 * @version 1.0
 * @date 2024-10-27 13:42:54
 */
public interface StoreService {

    /**
    * 主键查询
    *
    * @param id
    * @return
    */
    Store selectById(Long id);

    /**
    * 主键查询vo
    *
    * @param id
    * @return
    */
    StoreVo selectVoById(Long id);

    /**
    * 按照主键删除
    *
    * @param id
    */
    void deleteById(Long id);

    /**
    * 按照主键批量删除
    *
    * @param idList
    */
    void deleteByIdList(List<Long> idList);

    /**
    * 新增
    *
    * @param store
    * @return
    */
    Long insert(Store store);

    /**
    * 动态新增
    *
    * @param store
    * @return
    */
    Long insertSelective(Store store);

    /**
    * 更改
    *
    * @param store
    * @return
    */
    boolean update(Store store);

    /**
    * 动态修改
    *
    * @param record
    * @return
    */
    boolean updateByPrimaryKeySelective(Store record);

    /**
    * 保存
    *
    * @param saveOrUpdateVo
    * @return
    */
    boolean save(StoreSaveOrUpdateVo saveOrUpdateVo);

    /**
    * 编辑
    *
    * @param saveOrUpdateVo
    * @return
    */
    boolean modify(StoreSaveOrUpdateVo saveOrUpdateVo);

    /**
    * 列表
    *
    * @param storeSearchVo
    * @return
    */
    StoreVo selectOne(StoreSearchVo storeSearchVo);

    /**
    * 总数
    *
    * @param storeSearchVo
    * @return
    */
    Integer count(StoreSearchVo storeSearchVo);

    /**
    * 列表
    *
    * @param storeSearchVo
    * @return
    */
    List<StoreVo> selectList(StoreSearchVo storeSearchVo);

    /**
    * 分页查询
    *
    * @param storeSearchVo
    * @return
    */
    Page<StoreVo> selectPage(StoreSearchVo storeSearchVo);


    /**
     * 根据仓库IDs  产品id 查询库位及对应的库存数量
     * @param warehouseIdsList
     * @param productId
     * @return
     */
    List<StoreWarehouseVo> getWarehouseWithLocations(List<Long> warehouseIdsList, Long productId);

    List<StoreWarehouseLocationVo> getStoreWarehouseLocations(Long warehouseVoId, Long productId);

    /**
    * 批量新增数据（MyBatis原生foreach方法）
    *
    * @param entities 实例对象列表
    * @return 影响行数
    */
    boolean insertBatch(List<Store> entities);


    /**
     * 库存变更操作
     * @param stockActionDto
     * @return
     */
    boolean stockAction(StockActionDto stockActionDto);

    /**
     * 出入库
     * @param stockActionDto
     * @return
     */
    boolean stockInOrOut(StockActionDto stockActionDto);

    /**
     * 根据商品ID 和仓库ID 库位 id 查询库存
     * @param warehouseId
     * @param productIds
     * @return
     */
    List<Store> selectByCommodityIds(Long warehouseId, List<Long> warehouseLocationIds, List<Long> productIds);

    /**
     * 根据商品ID 和仓库ID 库位 id 查询库存
     * @param param
     * @return
     */
    String selectProduct(StoreSearchVo param);

    /**
     *
     * @param param
     * @return
     */
    List<StoreExport> selectStoreExportList(StoreSearchVo param);

    void flushStore();

    void flushStoreEnd();

    /**
     * 根据仓库ID 库位ID 项目ID 查询库存
     * @param param
     * @return
     */
    Page<StoreWarehouseLocationProjectVo> selectStoreWarehouseLocationProject(StoreWarehouseLocationSearchVo param);

    /**
     * 根据商品ID 查询仓库ID
     * @param productId
     * @return
     */
    List<Long> selectWarehouseId(Long productId);
}
